package com.juyu.miliao.scheduler.dao.mysql;

import com.juyu.miliao.scheduler.domin.GameAllRankingList;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Auther: 卜加超
 * @Date: 2019/8/20 12:36
 * @Description:
 */
@Repository
public class GameAllRankingListDao {
    @Resource
    private SqlSession sqlSession;
    public void  addGameRankingList(GameAllRankingList gameAllRankingList) {
       sqlSession.insert("addGameRankingList",gameAllRankingList);
    }

    public GameAllRankingList findListByUserId(Long userId, LocalDate now) {
        Map<String, Object> map = new HashMap<>(4);
        map.put("userId", userId);
        map.put("now", now);
        return  sqlSession.selectOne("findListByUserId",map);
    }

    public void updateGameRankingList(GameAllRankingList gameAllRankingList) {
        sqlSession.update("updateGameRankingList",gameAllRankingList);
    }

    public List<GameAllRankingList> selectGameListByDay(LocalDate localDate) {
        return sqlSession.selectList("selectGameListByDay",localDate);
    }

    public List<GameAllRankingList> selectGameListByWeek(LocalDate startTime,LocalDate endTime) {
        Map<String, Object> map = new HashMap<>(4);
        map.put("startTime", startTime);
        map.put("endTime", endTime);
        return sqlSession.selectList("selectGameListByWeek",map);
    }

    public List<GameAllRankingList> selectUserIsRotoByWeek(Long userId, LocalDate startTime,
                                                           LocalDate endTime) {
        Map<String, Object> map = new HashMap<>(4);
        map.put("userId",userId);
        map.put("startTime", startTime);
        map.put("endTime", endTime);
        return sqlSession.selectList("selectUserIsRotoByWeek",map);
    }
}
